-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not lint unnecessary_unwrap
in external macros
#5132
Conversation
I think, we want to continue this in macros. Just not, if the So macro_rules! m {
($a:expr) => {
if $a.is_some() {
$a.unwrap();
}
}
}
m!(Some(42)) should still get linted. That being said: I have no idea how differentiate these case. Maybe somehow with rust-clippy/clippy_lints/src/utils/mod.rs Lines 55 to 60 in d33c603
|
Oh, indeed! Re-covered it in 19ce66c, how about? |
Oh yeah, just allowing it in external macros works. At least for assert. The FP still exists when an internal macro is used though: macro_rules! m {
($a:expr, $b:expr) => {
if $a {
$b;
}
}
}
let x: Option<u32> = Some(42);
m!(x.is_some(), x.unwrap()) (At least, I think so) |
Ugh, it seems so. But I feel it's another FP and unrelated to the issue directly. If you think this PR is an improvement and doesn't have any other regressions, I'd say move on as it is and file that FP as a new issue. |
unnecessary_unwrap
in macrosunnecessary_unwrap
in external macros
Yeah, lets merge this, since it fixes the most prevalent issue with @bors r+ |
📌 Commit 19ce66c has been approved by |
Do not lint `unnecessary_unwrap` in external macros Fixes #5131 I think we shouldn't lint `{panicking, unnecessary}_unwrap` in macros, not just `assert!`. changelog: Fix false positive in `unnecessary_unwrap`
💔 Test failed - checks-travis |
Seems spurious:
|
@bors retry |
Do not lint `unnecessary_unwrap` in external macros Fixes #5131 I think we shouldn't lint `{panicking, unnecessary}_unwrap` in macros, not just `assert!`. changelog: Fix false positive in `unnecessary_unwrap`
☀️ Test successful - checks-travis, status-appveyor |
Fixes #5131
I think we shouldn't lint
{panicking, unnecessary}_unwrap
in macros, not justassert!
.changelog: Fix false positive in
unnecessary_unwrap